from peewee import CharField, DateTimeField, IntegerField
from playhouse.mysql_ext import JSONField

from application.db import get_database_connection
from application.db.mysql_db.base_mysql_model import BaseMysqlModel


class CnArticleAuthorUnitList(BaseMysqlModel):
    """中文文献库作者单位列表"""
    unit_id = CharField(max_length=32)  # 单位ID，cnun+入库时间(14位年月日时分秒+6位微秒)+6位随机数组成的30位字符串
    unit_name = CharField(max_length=512, index=True)  # 单位名称
    standard_unit = CharField(max_length=32, null=True, index=True)  # 机构单位标准名ID，表cn_article_unit_dict标识
    platform_id = JSONField(null=True)  # 单位对应其他平台标识，参考格式{"yiigle":"中华医学数据库的单位ID", "cnki":"知网的单位ID", ...}

    class Meta:
        table_name = 'cn_article_author_unit_list'
        database = get_database_connection('default')  # 使用默认数据库


if __name__ == '__main__':
    #
    data = CnArticleAuthorUnitList.select().dicts()
    for i in data:
        print(i)
        # break
